<script setup>
import OImage from "../setting/Images.vue";
import AlphaColor from "../setting/AlphaColor.vue";
import Slider from "../setting/Slider.vue";

const props = defineProps({
  config: {
    type: Object,
    required: true,
  },
  name: {
    type: String,
    default: "",
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});

const emits = defineEmits(["update:config", "change"]);

const form = ref({
  $position: { left: 0, top: 0 },
  $size: { width: "100%", height: "auto" },
  $positionType: "absolute",
  $show: false,
  color: "#f5f7fa",
  bottomHeight: 20,
});

const detail = computed({
  get: () => {
    return Object.assign({}, form.value, props.config);
  },
  set: (val) => {
    emits("update:config", val);
    emits("change", val);
  },
});

const onChange = (val) => {
  detail.value = detail.value;
};

onMounted(() => {
  nextTick(() => {
    onChange();
  });
});
</script>
<template>
  <el-form :model="detail" label-width="auto" :disabled="disabled">
    <OImage
      v-model="detail.img"
      v-model:show="detail.$show"
      name="背景图片"
      tips="建议尺寸：750px * ???"
      @change="onChange"
    />
    <AlphaColor v-model="detail.color" name="背景色" @change="onChange" />
    <Slider
      v-model="detail.bottomHeight"
      name="底部保留高度"
      :min="0"
      :max="50"
      @change="onChange"
    />
  </el-form>
</template>
